﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SCSService
{
    public class CampaignService
    {
        public List<Customer_Email_Campaign> GetListMailSettingNotPaging()
        {
            using (var data = new DataDataContext())
            {
                var type = (from emailCampain in data.Customer_Email_Campaigns
                            select emailCampain);
                return type.ToList();
            }

         
        }
    //    DALCampaign dalCam = new DALCampaign();
    //    OleDBOpenData oleOpen = new OleDBOpenData();

    //    public int CreateTemplateHtml(MailBroadcastDataAcess.Entity.TemplateHtml temp)
    //    {
    //        return dalCam.CreateTemplateHtml(temp);
    //    }

    //    public int UpdateTemplateHtml(MailBroadcastDataAcess.Entity.TemplateHtml temp)
    //    {
    //        return dalCam.UpdateTemplateHtml(temp);
    //    }

    //    public int DeleteTemplateHtml(int id)
    //    {
    //        return dalCam.DeleteTemplateHtml(id);
    //    }

    //    public List<MailBroadcastDataAcess.Entity.TemplateHtml> GetListTemplateHtmlPaging(out int TotalNumber,int currenPage, int pageSize, string name, string content, byte? status, int? userCreate, bool? deploy, DateTime? dateCreate)
    //    {
    //        TotalNumber = 0;
    //        List<MailBroadcastDataAcess.Entity.TemplateHtml> listTem = new List<MailBroadcastDataAcess.Entity.TemplateHtml>();
    //        try
    //        {
    //            NullableDataReader sRead = (NullableDataReader)dalCam.GetListTemplateHtml(currenPage,pageSize,name,content,status,userCreate,deploy,dateCreate);
    //            while (sRead.Read())
    //            {
    //                MailBroadcastDataAcess.Entity.TemplateHtml temp = new MailBroadcastDataAcess.Entity.TemplateHtml();
    //                temp.TempID = sRead.GetInt32("TempID");
    //                temp.Name = sRead.GetNullableString("Name");
    //                temp.Content = sRead.GetNullableString("Content");
    //                temp.Status = sRead.GetNullableByte("Status");
    //                temp.UserCreate = sRead.GetNullableInt32("UserCreate");
    //                temp.Deploy = sRead.GetNullableBoolean("Deploy");
    //                temp.DateCreate = sRead.GetNullableDateTime("DateCreate");
    //                TotalNumber = sRead.GetInt32("TotalNumber");
    //                listTem.Add(temp);
    //            }
    //            sRead.Close();
    //        }
    //        catch (Exception ex)
    //        {
    //            Console.Write(ex);
    //        }

    //        return listTem;
    //    }

    //    public List<MailBroadcastDataAcess.Entity.TemplateHtml> GetListTemplateHtmlNotPaging()
    //    {
    //        List<MailBroadcastDataAcess.Entity.TemplateHtml> listTem = new List<MailBroadcastDataAcess.Entity.TemplateHtml>();
    //        try
    //        {
    //            NullableDataReader sRead = (NullableDataReader)dalCam.GetListTemplateNotPaging();
    //            while (sRead.Read())
    //            {
    //                MailBroadcastDataAcess.Entity.TemplateHtml temp = new MailBroadcastDataAcess.Entity.TemplateHtml();
    //                temp.TempID = sRead.GetInt32("TempID");
    //                temp.Name = sRead.GetNullableString("Name");
    //                temp.Content = sRead.GetNullableString("Content");
    //                temp.Status = sRead.GetNullableByte("Status");
    //                temp.UserCreate = sRead.GetNullableInt32("UserCreate");
    //                temp.Deploy = sRead.GetNullableBoolean("Deploy");
    //                temp.DateCreate = sRead.GetNullableDateTime("DateCreate");
    //                listTem.Add(temp);
    //            }
    //            sRead.Close();
    //        }
    //        catch (Exception ex)
    //        {
    //            Console.Write(ex);
    //        }

    //        return listTem;
    //    }

    //    public MailBroadcastDataAcess.Entity.TemplateHtml GetTemplateHtmlByID(int id)
    //    {
    //        MailBroadcastDataAcess.Entity.TemplateHtml temp = new MailBroadcastDataAcess.Entity.TemplateHtml();
    //        try
    //        {
    //            NullableDataReader sRead = (NullableDataReader)dalCam.GetTemplateByID(id);
    //            while (sRead.Read())
    //            {
    //                temp.TempID = sRead.GetInt32("TempID");
    //                temp.Name = sRead.GetNullableString("Name");
    //                temp.Content = sRead.GetNullableString("Content");
    //                temp.Status = sRead.GetNullableByte("Status");
    //                temp.UserCreate = sRead.GetNullableInt32("UserCreate");
    //                temp.Deploy = sRead.GetNullableBoolean("Deploy");
    //                temp.DateCreate = sRead.GetNullableDateTime("DateCreate");

    //            }
    //            sRead.Close();
    //        }
    //        catch (Exception ex)
    //        {
    //            Console.Write(ex);
    //        }

    //        return temp;
    //    }

        public int CreateAttachFile(Customer_Email_Attach_File att)
        {
            using(var data =new DataDataContext())
            {
                data.Customer_Email_Attach_Files.InsertOnSubmit(att);
                data.SubmitChanges();
                return att.AttachID;
            }
        }

    //    public int UpdateAttachFile(MailBroadcastDataAcess.Entity.AttachFile att)
    //    {
    //        return dalCam.UpdateAttachFile(att);
    //    }

    //    public int DeleteAttachFile(int id)
    //    {
    //        return dalCam.DeleteAttachFile(id);
    //    }

    //    public List<MailBroadcastDataAcess.Entity.AttachFile> GetListAttachFilePaging(out int TotalNumber, int currenPage, int pageSize, string fileExtend, string location, byte? status, bool? typeMail, string fileName, byte? typeAttach, int? customerID)
    //    {
    //        TotalNumber = 0;
    //        List<MailBroadcastDataAcess.Entity.AttachFile> listAtt = new List<MailBroadcastDataAcess.Entity.AttachFile>();
    //        try
    //        {
    //            NullableDataReader sRead = (NullableDataReader)dalCam.GetListAttachFile(currenPage, pageSize, fileExtend, location, status, typeMail, fileName,typeAttach,customerID);
    //            while (sRead.Read())
    //            {
    //                MailBroadcastDataAcess.Entity.AttachFile att = new MailBroadcastDataAcess.Entity.AttachFile();
    //                att.AttachID = sRead.GetInt32("AttachID");
    //                att.FileExtend = sRead.GetNullableString("FileExtend");
    //                att.Location = sRead.GetNullableString("Location");
    //                att.Status = sRead.GetNullableByte("Status");
    //                att.TypeMail = sRead.GetNullableBoolean("TypeMail");
    //                att.FileName = sRead.GetNullableString("FileName");
    //                att.TypeAttach = sRead.GetNullableByte("TypeAttach");
    //                att.CampaignID = sRead.GetNullableInt32("CampaignID");
    //                TotalNumber = sRead.GetInt32("TotalNumber");
    //                listAtt.Add(att);
    //            }
    //            sRead.Close();
    //        }
    //        catch (Exception ex)
    //        {
    //            Console.Write(ex);
    //        }

    //        return listAtt;
    //    }

    //    public MailBroadcastDataAcess.Entity.AttachFile GetAttachFileByID(int id)
    //    {
    //        MailBroadcastDataAcess.Entity.AttachFile att = new MailBroadcastDataAcess.Entity.AttachFile();
    //        try
    //        {
    //            NullableDataReader sRead = (NullableDataReader)dalCam.GetAttachFileByID(id);
    //            while (sRead.Read())
    //            {
    //                att.AttachID = sRead.GetInt32("AttachID");
    //                att.FileExtend = sRead.GetNullableString("FileExtend");
    //                att.Location = sRead.GetNullableString("Location");
    //                att.Status = sRead.GetNullableByte("Status");
    //                att.TypeMail = sRead.GetNullableBoolean("TypeMail");
    //                att.FileName = sRead.GetNullableString("FileName");
    //                att.TypeAttach = sRead.GetNullableByte("TypeAttach");
    //                att.CampaignID = sRead.GetNullableInt32("CampaignID");

    //            }
    //            sRead.Close();
    //        }
    //        catch (Exception ex)
    //        {
    //            Console.Write(ex);
    //        }

    //        return att;
    //    }

    //    public int CreateCampaign(MailBroadcastDataAcess.Entity.Campaign cam)
    //    {
    //        return dalCam.CreateCampaign(cam);
    //    }

    //    public int UpdateCampaign(MailBroadcastDataAcess.Entity.Campaign cam)
    //    {
    //        return dalCam.UpdateCampaign(cam);
    //    }

    //    public int DeleteCampaign(int id)
    //    {
    //        return dalCam.DeleteCampaign(id);
    //    }

    //    public List<MailBroadcastDataAcess.Entity.Campaign> GetListCampaignPaging(out int TotalNumber, int currenPage, int pageSize, string name, byte? status, int? configID, string description, int? userCreate, bool? deploy, int? scheduleID, string content, int? clientID, DateTime? createDate)
    //    {
    //        TotalNumber = 0;
    //        List<MailBroadcastDataAcess.Entity.Campaign> listCam = new List<MailBroadcastDataAcess.Entity.Campaign>();
    //        try
    //        {
    //            NullableDataReader sRead = (NullableDataReader)dalCam.GetListCampaignWithClientID(currenPage, pageSize, name, status, configID, description, userCreate, deploy, scheduleID, content, clientID, createDate);
    //            while (sRead.Read())
    //            {
    //                MailBroadcastDataAcess.Entity.Campaign cam = new MailBroadcastDataAcess.Entity.Campaign();
    //                cam.CampaignID = sRead.GetInt32("CampaignID");
    //                cam.Name = sRead.GetNullableString("Name");
    //                cam.Status = sRead.GetNullableByte("Status");
    //                cam.ConfigID = sRead.GetNullableInt32("ConfigID");
    //                cam.Description = sRead.GetNullableString("Description");
    //                cam.UserCreate = sRead.GetNullableInt32("UserCreate");
    //                cam.Deploy = sRead.GetNullableBoolean("Deploy");
    //                cam.ScheduleID = sRead.GetNullableInt32("ScheduleID");
    //                cam.Content = sRead.GetNullableString("Content");
    //                cam.CreateDate = sRead.GetNullableDateTime("CreateDate");
    //                TotalNumber = sRead.GetInt32("TotalNumber");
    //                listCam.Add(cam);
    //            }
    //            sRead.Close();
    //        }
    //        catch (Exception ex)
    //        {
    //            Console.Write(ex);
    //        }

    //        return listCam;
    //    }

    //    public List<MailBroadcastDataAcess.Entity.Campaign> GetListCampaignBySchedule(int scheduleID)
    //    {
    //        List<MailBroadcastDataAcess.Entity.Campaign> listCam = new List<MailBroadcastDataAcess.Entity.Campaign>();
    //        try
    //        {
    //            NullableDataReader sRead = (NullableDataReader)dalCam.GetListCampaignBySchedule(scheduleID);
    //            while (sRead.Read())
    //            {
    //                MailBroadcastDataAcess.Entity.Campaign cam = new MailBroadcastDataAcess.Entity.Campaign();
    //                cam.CampaignID = sRead.GetInt32("CampaignID");
    //                cam.Name = sRead.GetNullableString("Name");
    //                cam.Status = sRead.GetNullableByte("Status");
    //                cam.ConfigID = sRead.GetNullableInt32("ConfigID");
    //                cam.Description = sRead.GetNullableString("Description");
    //                cam.UserCreate = sRead.GetNullableInt32("UserCreate");
    //                cam.Deploy = sRead.GetNullableBoolean("Deploy");
    //                cam.ScheduleID = sRead.GetNullableInt32("ScheduleID");
    //                cam.Content = sRead.GetNullableString("Content");
    //                cam.CreateDate = sRead.GetNullableDateTime("CreateDate");
    //                listCam.Add(cam);
    //            }
    //            sRead.Close();
    //        }
    //        catch (Exception ex)
    //        {
    //            Console.Write(ex);
    //        }

    //        return listCam;
    //    }

    //    public MailBroadcastDataAcess.Entity.Campaign GetCampaignByID(int id)
    //    {
    //        MailBroadcastDataAcess.Entity.Campaign cam = new MailBroadcastDataAcess.Entity.Campaign();
    //        try
    //        {
    //            NullableDataReader sRead = (NullableDataReader)dalCam.GetCampaignByID(id);
    //            while (sRead.Read())
    //            {
    //                cam.CampaignID = sRead.GetInt32("CampaignID");
    //                cam.Name = sRead.GetNullableString("Name");
    //                cam.Status = sRead.GetNullableByte("Status");
    //                cam.ConfigID = sRead.GetNullableInt32("ConfigID");
    //                cam.Description = sRead.GetNullableString("Description");
    //                cam.UserCreate = sRead.GetNullableInt32("UserCreate");
    //                cam.Deploy = sRead.GetNullableBoolean("Deploy");
    //                cam.ScheduleID = sRead.GetNullableInt32("ScheduleID");
    //                cam.Content = sRead.GetNullableString("Content");
    //                cam.CreateDate = sRead.GetNullableDateTime("CreateDate");
    //            }
    //            sRead.Close();
    //        }
    //        catch (Exception ex)
    //        {
    //            Console.Write(ex);
    //        }

    //        return cam;
    //    }

    //    public int CreateClient(MailBroadcastDataAcess.Entity.Client client)
    //    {
    //        return dalCam.CreateClient(client);
    //    }

    //    public int UpdateClient(MailBroadcastDataAcess.Entity.Client client)
    //    {
    //        return dalCam.UpdateClient(client);
    //    }

    //    public int DeleteClient(int id)
    //    {
    //        return dalCam.DeleteClient(id);
    //    }

    //    public List<MailBroadcastDataAcess.Entity.Client> GetListClientDrop()
    //    {
    //        List<MailBroadcastDataAcess.Entity.Client> listClient = new List<MailBroadcastDataAcess.Entity.Client>();
    //        try
    //        {
    //            NullableDataReader sRead = (NullableDataReader)dalCam.GetListClientToDrop();
    //            while (sRead.Read())
    //            {
    //                MailBroadcastDataAcess.Entity.Client client = new MailBroadcastDataAcess.Entity.Client();
    //                client.ClientID = sRead.GetInt32("ClientID");
    //                client.Name = sRead.GetNullableString("Name");
    //                client.UserCreate = sRead.GetNullableInt32("UserCreate");
    //                client.Deploy = sRead.GetNullableBoolean("Deploy");
    //                client.CreateDate = sRead.GetNullableDateTime("CreateDate");
    //                client.Address = sRead.GetNullableString("Address");
    //                client.Email = sRead.GetNullableString("Email");
    //                client.Phone = sRead.GetNullableString("Phone");
    //                listClient.Add(client);
    //            }
    //            sRead.Close();
    //        }
    //        catch (Exception ex)
    //        {
    //            Console.Write(ex);
    //        }

    //        return listClient;
    //    }

    //    public List<MailBroadcastDataAcess.Entity.Client> GetListClientPaging(out int TotalNumber, int currenPage, int pageSize, string name,
    //        int? userCreate, bool? deploy, DateTime? createDate, string address, string email, string phone)
    //    {
    //        TotalNumber = 0;
    //        List<MailBroadcastDataAcess.Entity.Client> listClient = new List<MailBroadcastDataAcess.Entity.Client>();
    //        try
    //        {
    //            NullableDataReader sRead = (NullableDataReader)dalCam.GetListClient(currenPage, pageSize, name,userCreate,deploy,createDate,address,email,phone );
    //            while (sRead.Read())
    //            {
    //                MailBroadcastDataAcess.Entity.Client client = new MailBroadcastDataAcess.Entity.Client();
    //                client.ClientID = sRead.GetInt32("ClientID");
    //                client.Name = sRead.GetNullableString("Name");
    //                client.UserCreate = sRead.GetNullableInt32("UserCreate");
    //                client.Deploy = sRead.GetNullableBoolean("Deploy");
    //                client.CreateDate = sRead.GetNullableDateTime("CreateDate");
    //                client.Address = sRead.GetNullableString("Address");
    //                client.Email = sRead.GetNullableString("Email");
    //                client.Phone = sRead.GetNullableString("Phone");
    //                TotalNumber = sRead.GetInt32("TotalNumber");
    //                listClient.Add(client);
    //            }
    //            sRead.Close();
    //        }
    //        catch (Exception ex)
    //        {
    //            Console.Write(ex);
    //        }

    //        return listClient;
    //    }

    //    public MailBroadcastDataAcess.Entity.Client GetClientByID(int id)
    //    {
    //        MailBroadcastDataAcess.Entity.Client client = new MailBroadcastDataAcess.Entity.Client();
    //        try
    //        {
    //            NullableDataReader sRead = (NullableDataReader)dalCam.GetClientByID(id);
    //            while (sRead.Read())
    //            {
    //                client.ClientID = sRead.GetInt32("ClientID");
    //                client.Name = sRead.GetNullableString("Name");
    //                client.UserCreate = sRead.GetNullableInt32("UserCreate");
    //                client.Deploy = sRead.GetNullableBoolean("Deploy");
    //                client.CreateDate = sRead.GetNullableDateTime("CreateDate");
    //                client.Address = sRead.GetNullableString("Address");
    //                client.Email = sRead.GetNullableString("Email");
    //                client.Phone = sRead.GetNullableString("Phone");

    //            }
    //            sRead.Close();
    //        }
    //        catch (Exception ex)
    //        {
    //            Console.Write(ex);
    //        }

    //        return client;
    //    }

    //    public int CreateCampaignAttachFile(MailBroadcastDataAcess.Entity.CampaignAttachFile camAtt)
    //    {
    //        return dalCam.CreateCampaignAttachFile(camAtt);
    //    }

    //    public int DeleteCampaignAttachFile(int id)
    //    {
    //        return dalCam.DeleteCampaignAttachFile(id);
    //    }

    //    public MailBroadcastDataAcess.Entity.CampaignAttachFile GetCampaignAttachFileByCampaignIDAndAttachID(int campaignid, int attachid)
    //    {
    //        MailBroadcastDataAcess.Entity.CampaignAttachFile cam = new MailBroadcastDataAcess.Entity.CampaignAttachFile();
    //        try
    //        {
    //            NullableDataReader sRead = (NullableDataReader)dalCam.GetCampaignAttachFileByCampaignIDAndAttachID(campaignid,attachid);
    //            while (sRead.Read())
    //            {
    //                cam.CampaignAttachID = sRead.GetInt32("CampaignAttachID");
    //                cam.CampaignID = sRead.GetNullableInt32("CampaignID");
    //                cam.AttachID = sRead.GetNullableInt32("AttachID");
    //            }
    //            sRead.Close();
    //        }
    //        catch (Exception ex)
    //        {
    //            Console.Write(ex);
    //        }

    //        return cam;
    //    }

    //    public int CreateStaff(MailBroadcastDataAcess.Entity.Staff staff)
    //    {
    //        return dalCam.CreateStaff(staff);
    //    }

    //    public int UpdateStaff(MailBroadcastDataAcess.Entity.Staff staff)
    //    {
    //        return dalCam.UpdateStaff(staff);
    //    }

    //    public int DeleteStaff(int id)
    //    {
    //        return dalCam.DeleteStaff(id);
    //    }

    //    public MailBroadcastDataAcess.Entity.Staff GetStaffByID(int id)
    //    {
    //        MailBroadcastDataAcess.Entity.Staff staff = new MailBroadcastDataAcess.Entity.Staff();
    //        try
    //        {
    //            NullableDataReader sRead = (NullableDataReader)dalCam.GetStaffByID(id);
    //            while (sRead.Read())
    //            {
    //                staff.StaffID = sRead.GetInt32("StaffID");
    //                staff.StaffName = sRead.GetNullableString("StaffName");
    //                staff.StaffEmail = sRead.GetNullableString("StaffEmail");
    //                staff.StaffPhone = sRead.GetNullableString("StaffPhone");
    //                staff.StaffPhone2 = sRead.GetNullableString("StaffPhone2");
    //                staff.Designation = sRead.GetNullableString("Designation");
    //                staff.ClientID = sRead.GetNullableInt32("ClientID");
    //                staff.CreateDate = sRead.GetNullableDateTime("CreateDate");

    //            }
    //            sRead.Close();
    //        }
    //        catch (Exception ex)
    //        {
    //            Console.Write(ex);
    //        }

    //        return staff;
    //    }

    //    public List<MailBroadcastDataAcess.Entity.Staff> GetListStaffByClientID(int? clientID)
    //    {
    //        List<MailBroadcastDataAcess.Entity.Staff> listStaff = new List<MailBroadcastDataAcess.Entity.Staff>();
    //        try
    //        {
    //            NullableDataReader sRead = (NullableDataReader)dalCam.GetListStaffNotPaging(clientID);
    //            while (sRead.Read())
    //            {
    //                MailBroadcastDataAcess.Entity.Staff staff = new MailBroadcastDataAcess.Entity.Staff();
    //                staff.StaffID = sRead.GetInt32("StaffID");
    //                staff.StaffName = sRead.GetNullableString("StaffName");
    //                staff.StaffEmail = sRead.GetNullableString("StaffEmail");
    //                staff.StaffPhone = sRead.GetNullableString("StaffPhone");
    //                staff.StaffPhone2 = sRead.GetNullableString("StaffPhone2");
    //                staff.Designation = sRead.GetNullableString("Designation");
    //                staff.ClientID = sRead.GetNullableInt32("ClientID");
    //                staff.CreateDate = sRead.GetNullableDateTime("CreateDate");
    //                listStaff.Add(staff);
    //            }
    //            sRead.Close();
    //        }
    //        catch (Exception ex)
    //        {
    //            Console.Write(ex);
    //        }

    //        return listStaff;
    //    }

    //    public List<MailBroadcastDataAcess.Entity.Staff> GetListStaffAplink()
    //    {
    //        List<MailBroadcastDataAcess.Entity.Staff> listStaff = new List<MailBroadcastDataAcess.Entity.Staff>();
    //        try
    //        {
    //            NullableDataReader sRead = (NullableDataReader)dalCam.GetListStaffAplink();
    //            while (sRead.Read())
    //            {
    //                MailBroadcastDataAcess.Entity.Staff staff = new MailBroadcastDataAcess.Entity.Staff();
    //                staff.StaffID = sRead.GetInt32("StaffID");
    //                staff.StaffName = sRead.GetNullableString("StaffName");
    //                staff.StaffEmail = sRead.GetNullableString("StaffEmail");
    //                staff.StaffPhone = sRead.GetNullableString("StaffPhone");
    //                staff.StaffPhone2 = sRead.GetNullableString("StaffPhone2");
    //                staff.Designation = sRead.GetNullableString("Designation");
    //                staff.ClientID = sRead.GetNullableInt32("ClientID");
    //                listStaff.Add(staff);
    //            }
    //            sRead.Close();
    //        }
    //        catch (Exception ex)
    //        {
    //            Console.Write(ex);
    //        }

    //        return listStaff;
    //    }


    //    public List<MailBroadcastDataAcess.Entity.Staff> GetListStaffPaging(out int TotalNumber, int currenPage, int pageSize, string staffName, string staffEmail,
    //        string staffPhone, string staffPhone2, string designation, int? clientID, DateTime? createDate)
    //    {
    //        TotalNumber = 0;
    //        List<MailBroadcastDataAcess.Entity.Staff> listStaff = new List<MailBroadcastDataAcess.Entity.Staff>();
    //        try
    //        {
    //            NullableDataReader sRead = (NullableDataReader)dalCam.GetListStaffPaging(currenPage, pageSize, staffName, staffEmail, staffPhone,clientID, staffPhone2, designation,createDate);
    //            while (sRead.Read())
    //            {
    //                MailBroadcastDataAcess.Entity.Staff staff = new MailBroadcastDataAcess.Entity.Staff();
    //                staff.StaffID = sRead.GetInt32("StaffID");
    //                staff.StaffName = sRead.GetNullableString("StaffName");
    //                staff.StaffEmail = sRead.GetNullableString("StaffEmail");
    //                staff.StaffPhone = sRead.GetNullableString("StaffPhone");
    //                staff.StaffPhone2 = sRead.GetNullableString("StaffPhone2");
    //                staff.Designation = sRead.GetNullableString("Designation");
    //                staff.ClientID = sRead.GetNullableInt32("ClientID");
    //                TotalNumber = sRead.GetInt32("TotalNumber");
    //                listStaff.Add(staff);
    //            }
    //            sRead.Close();
    //        }
    //        catch (Exception ex)
    //        {
    //            Console.Write(ex);
    //        }

    //        return listStaff;
    //    }

    //    public int CreateClientStaffCampaign(MailBroadcastDataAcess.Entity.ClientStaffCampaign clientStaff)
    //    {
    //        return dalCam.CreateClientStaffCampaign(clientStaff);
    //    }

    //    public int UpdateClientStaffCampaign(MailBroadcastDataAcess.Entity.ClientStaffCampaign clientStaff)
    //    {
    //        return dalCam.UpdateClientStaffCampaign(clientStaff);
    //    }

    //    public int DeleteClientStaffCampaign(int id)
    //    {
    //        return dalCam.DeleteClientStaffCampaign(id);
    //    }

    //    public int CreateMailSetting(MailBroadcastDataAcess.Entity.MailSetting mailSetting)
    //    {
    //        return dalCam.CreateMailSetting(mailSetting);
    //    }

    //    public int UpdateMailSetting(MailBroadcastDataAcess.Entity.MailSetting mailSetting)
    //    {
    //        return dalCam.UpdateMailSetting(mailSetting);
    //    }

    //    public int DeleteMailSetting(int id)
    //    {
    //        return dalCam.DeleteMailSetting(id);
    //    }

    //    public List<MailBroadcastDataAcess.Entity.MailSetting> GetListMailSettingPaging(out int TotalNumber, int currenPage, int pageSize, string SMTPServer, string UserName,
    //        string Password, string SMTPPort, byte? MailboxStatus, long? SendInterval, string POP3Port, DateTime? createDate)
    //    {
    //        TotalNumber = 0;
    //        List<MailBroadcastDataAcess.Entity.MailSetting> listMailSetting = new List<MailBroadcastDataAcess.Entity.MailSetting>();
    //        try
    //        {
    //            NullableDataReader sRead = (NullableDataReader)dalCam.GetListMailSetting(currenPage, pageSize, SMTPServer, UserName, Password, SMTPPort, MailboxStatus, SendInterval, POP3Port, createDate);
    //            while (sRead.Read())
    //            {
    //                MailBroadcastDataAcess.Entity.MailSetting setting = new MailBroadcastDataAcess.Entity.MailSetting();
    //                setting.ConfigID = sRead.GetInt32("ConfigID");
    //                setting.SMTPServer = sRead.GetNullableString("SMTPServer");
    //                setting.UserName = sRead.GetNullableString("UserName");
    //                setting.Password = sRead.GetNullableString("Password");
    //                setting.SMTPPort = sRead.GetNullableString("SMTPPort");
    //                setting.MailboxStatus = sRead.GetNullableByte("MailboxStatus");
    //                setting.POP3Port = sRead.GetNullableString("POP3Port");
    //                setting.SendInterval = sRead.GetNullableInt32("SendInterval");
    //                TotalNumber = sRead.GetInt32("TotalNumber");
    //                listMailSetting.Add(setting);
    //            }
    //            sRead.Close();
    //        }
    //        catch (Exception ex)
    //        {
    //            Console.Write(ex);
    //        }

    //        return listMailSetting;
    //    }


        public Customer_Email_Campaign GetMailSettingByID(int id)
        {
            Customer_Email_Campaign setting = new Customer_Email_Campaign();
            using(var data=new DataDataContext())
            {
                var type=(from st in data.Customer_Email_Campaigns
                              where st.CampaignID==id
                              select st).FirstOrDefault();
                return type;
            }

            
        }

      

    //    public int CreateSchedule(MailBroadcastDataAcess.Entity.Schedule schedule)
    //    {
    //        return dalCam.CreateSchedule(schedule);
    //    }

    //    public int UpdateSchedule(MailBroadcastDataAcess.Entity.Schedule schedule)
    //    {
    //        return dalCam.UpdateSchedule(schedule);
    //    }

    //    public int DeleteSchedule(int id)
    //    {
    //        return dalCam.DeleteSchedule(id);
    //    }

    //    public MailBroadcastDataAcess.Entity.Schedule GetScheduleByID(int id)
    //    {
    //        MailBroadcastDataAcess.Entity.Schedule schedule = new MailBroadcastDataAcess.Entity.Schedule();
    //        try
    //        {
    //            NullableDataReader sRead = (NullableDataReader)dalCam.GetScheduleByID(id);
    //            while (sRead.Read())
    //            {
    //                schedule.ScheduleID = sRead.GetInt32("ScheduleID");
    //                schedule.ScheduleName = sRead.GetNullableString("ScheduleName");
    //                schedule.SendDate = sRead.GetNullableInt32("SendDate");
    //                schedule.SendMonth = sRead.GetNullableString("SendMonth");
    //                schedule.DateRun = sRead.GetDateTime("DateRun");
    //            }
    //            sRead.Close();
    //        }
    //        catch (Exception ex)
    //        {
    //            Console.Write(ex);
    //        }

    //        return schedule;
    //    }

    //    public List<MailBroadcastDataAcess.Entity.Schedule> GetListSchedulePaging(out int TotalNumber, int currenPage, int pageSize, string ScheduleName, int? SendDate,
    //       string SendMonth, DateTime? createDate)
    //    {
    //        TotalNumber = 0;
    //        List<MailBroadcastDataAcess.Entity.Schedule> listSchedule = new List<MailBroadcastDataAcess.Entity.Schedule>();
    //        try
    //        {
    //            NullableDataReader sRead = (NullableDataReader)dalCam.GetListSchedule(currenPage, pageSize, ScheduleName, SendDate, SendMonth,createDate);
    //            while (sRead.Read())
    //            {
    //                MailBroadcastDataAcess.Entity.Schedule schedule = new MailBroadcastDataAcess.Entity.Schedule();
    //                schedule.ScheduleID = sRead.GetInt32("ScheduleID");
    //                schedule.ScheduleName = sRead.GetNullableString("ScheduleName");
    //                schedule.SendDate = sRead.GetNullableInt32("SendDate");
    //                schedule.SendMonth = sRead.GetNullableString("SendMonth");
    //                schedule.DateRun = sRead.GetDateTime("DateRun");
    //                TotalNumber = sRead.GetInt32("TotalNumber");
    //                listSchedule.Add(schedule);
    //            }
    //            sRead.Close();
    //        }
    //        catch (Exception ex)
    //        {
    //            Console.Write(ex);
    //        }

    //        return listSchedule;
    //    }

    //    public List<MailBroadcastDataAcess.Entity.Schedule> GetListScheduleNotPaging()
    //    {
    //        List<MailBroadcastDataAcess.Entity.Schedule> listSchedule = new List<MailBroadcastDataAcess.Entity.Schedule>();
    //        try
    //        {
    //            NullableDataReader sRead = (NullableDataReader)dalCam.GetListScheduleNotPaging();
    //            while (sRead.Read())
    //            {
    //                MailBroadcastDataAcess.Entity.Schedule schedule = new MailBroadcastDataAcess.Entity.Schedule();
    //                schedule.ScheduleID = sRead.GetInt32("ScheduleID");
    //                schedule.ScheduleName = sRead.GetNullableString("ScheduleName");
    //                schedule.SendDate = sRead.GetNullableInt32("SendDate");
    //                schedule.SendMonth = sRead.GetNullableString("SendMonth");
    //                schedule.DateRun = sRead.GetDateTime("DateRun");
    //                listSchedule.Add(schedule);
    //            }
    //            sRead.Close();
    //        }
    //        catch (Exception ex)
    //        {
    //            Console.Write(ex);
    //        }

    //        return listSchedule;
    //    }

    //    public List<MailBroadcastDataAcess.Entity.Schedule> GetListScheduleInDate(DateTime date)
    //    {
    //        List<MailBroadcastDataAcess.Entity.Schedule> listSchedule = new List<MailBroadcastDataAcess.Entity.Schedule>();
    //        try
    //        {
    //            NullableDataReader sRead = (NullableDataReader)dalCam.GetListScheduleInDate(date);
    //            while (sRead.Read())
    //            {
    //                MailBroadcastDataAcess.Entity.Schedule schedule = new MailBroadcastDataAcess.Entity.Schedule();
    //                schedule.ScheduleID = sRead.GetInt32("ScheduleID");
    //                schedule.ScheduleName = sRead.GetNullableString("ScheduleName");
    //                schedule.SendDate = sRead.GetNullableInt32("SendDate");
    //                schedule.SendMonth = sRead.GetNullableString("SendMonth");
    //                schedule.DateRun = sRead.GetDateTime("DateRun");
    //                listSchedule.Add(schedule);
    //            }
    //            sRead.Close();
    //        }
    //        catch (Exception ex)
    //        {
    //            Console.Write(ex);
    //        }

    //        return listSchedule;
    //    }

    //    public int CreateCustomerCampaign(MailBroadcastDataAcess.Entity.CustomerCampaign customerCampaign)
    //    {
    //        return dalCam.CreateCustomerCampaign(customerCampaign);
    //    }

    //    public int UpdateCustomerCampaign(MailBroadcastDataAcess.Entity.CustomerCampaign customerCampaign)
    //    {
    //        return dalCam.UpdateCustomerCampaign(customerCampaign);
    //    }

    //    public int DeleteCustomerCampaign(int id)
    //    {
    //        return dalCam.DeleteCustomerCampaign(id);
    //    }

    //    public MailBroadcastDataAcess.Entity.CustomerCampaign GetCustomerCampaignByCampaignIDAndClientID(int campaignID, int clientID)
    //    {
    //        MailBroadcastDataAcess.Entity.CustomerCampaign customerCampaign = new MailBroadcastDataAcess.Entity.CustomerCampaign();
    //        try
    //        {
    //            NullableDataReader sRead = (NullableDataReader)dalCam.GetCustomerCampaignByCampaignIDAndClientID(campaignID,clientID);
    //            while (sRead.Read())
    //            {
                   
    //                customerCampaign.CustomerCampaignID = sRead.GetInt32("CustomerCampaignID");
    //                customerCampaign.CampaignID = sRead.GetNullableInt32("CampaignID");
    //                customerCampaign.ClientID = sRead.GetNullableInt32("ClientID");
    //                customerCampaign.Status = sRead.GetNullableByte("Status");
    //            }
    //            sRead.Close();
    //        }
    //        catch (Exception ex)
    //        {
    //            Console.Write(ex);
    //        }

    //        return customerCampaign;
    //    }

    //    public int CreateEmailCustomer(MailBroadcastDataAcess.Entity.EmailCustomer emailCustomer)
    //    {
    //        return dalCam.CreateEmailCustomer(emailCustomer);
    //    }

    //    public int UpdateEmailCustomer(MailBroadcastDataAcess.Entity.EmailCustomer emailCustomer)
    //    {
    //        return dalCam.UpdateEmailCustomer(emailCustomer);
    //    }

    //    public int DeleteEmailCustomer(int id)
    //    {
    //        return dalCam.DeleteEmailCustomer(id);
    //    }

    //    public MailBroadcastDataAcess.Entity.EmailCustomer GetEmailCustomerByID(int id)
    //    {
    //        MailBroadcastDataAcess.Entity.EmailCustomer emailCustomer = new MailBroadcastDataAcess.Entity.EmailCustomer();
    //        try
    //        {
    //            NullableDataReader sRead = (NullableDataReader)dalCam.GetEmailCustomerByID(id);
    //            while (sRead.Read())
    //            {
    //                emailCustomer.EmailID = sRead.GetInt32("EmailID");
    //                emailCustomer.EmailAddress = sRead.GetNullableString("EmailAddress");
    //                emailCustomer.Status = sRead.GetNullableByte("Status");
    //                emailCustomer.CustomerID = sRead.GetNullableInt32("CustomerID");
    //            }
    //            sRead.Close();
    //        }
    //        catch (Exception ex)
    //        {
    //            Console.Write(ex);
    //        }

    //        return emailCustomer;
    //    }

    //    public List<MailBroadcastDataAcess.Entity.EmailCustomer> GetListEmailCustomer(int customerID)
    //    {
    //        List<MailBroadcastDataAcess.Entity.EmailCustomer> listEmailCustomer = new List<MailBroadcastDataAcess.Entity.EmailCustomer>();
    //        try
    //        {
    //            NullableDataReader sRead = (NullableDataReader)dalCam.GetListEmailCustomerByCustomerID(customerID);
    //            while (sRead.Read())
    //            {
    //                MailBroadcastDataAcess.Entity.EmailCustomer emailCustomer = new MailBroadcastDataAcess.Entity.EmailCustomer();
    //                emailCustomer.EmailID = sRead.GetInt32("EmailID");
    //                emailCustomer.EmailAddress = sRead.GetNullableString("EmailAddress");
    //                emailCustomer.Status = sRead.GetNullableByte("Status");
    //                emailCustomer.CustomerID = sRead.GetNullableInt32("CustomerID");
    //                listEmailCustomer.Add(emailCustomer);
    //            }
    //            sRead.Close();
    //        }
    //        catch (Exception ex)
    //        {
    //            Console.Write(ex);
    //        }

    //        return listEmailCustomer;
    //    }

    //    public int CreateCustomer(MailBroadcastDataAcess.Entity.Customer customer)
    //    {
    //        return dalCam.CreateCustomer(customer);
    //    }

    //    public int UpdateCustomer(MailBroadcastDataAcess.Entity.Customer customer)
    //    {
    //        return dalCam.UpdateCustomer(customer);
    //    }

    //    public int DeleteCustomer(int id)
    //    {
    //        return dalCam.DeleteCustomer(id);
    //    }

    //    public MailBroadcastDataAcess.Entity.Customer GetCustomerByID(int id)
    //    {
    //        MailBroadcastDataAcess.Entity.Customer customer = new MailBroadcastDataAcess.Entity.Customer();
    //        try
    //        {
    //            NullableDataReader sRead = (NullableDataReader)dalCam.GetCustomerByID(id);
    //            while (sRead.Read())
    //            {
    //                customer.CustomerID = sRead.GetInt32("CustomerID");
    //                customer.CustomerName = sRead.GetNullableString("CustomerName");
    //                customer.Address = sRead.GetNullableString("Address");
    //                customer.Phone = sRead.GetNullableString("Phone");
    //                customer.Mobile = sRead.GetNullableString("Mobile");
    //                customer.Status = sRead.GetNullableByte("Status");
    //                customer.CountryID = sRead.GetNullableInt32("CountryID");
    //                customer.CustomerCampaignID = sRead.GetNullableInt32("CustomerCampaignID");
    //                customer.CreateDate = sRead.GetNullableDateTime("CreateDate");
    //            }
    //            sRead.Close();
    //        }
    //        catch (Exception ex)
    //        {
    //            Console.Write(ex);
    //        }

    //        return customer;
    //    }

    //    public List<MailBroadcastDataAcess.Entity.Customer> GetListCustomerPaging(out int TotalNumber, int currenPage, int pageSize, string CustomerName, string Address,
    //       string Phone, string Mobile, byte? Status, int? CountryID, int? CustomerCampaignID, DateTime? createDate)
    //    {
    //        TotalNumber = 0;
    //        List<MailBroadcastDataAcess.Entity.Customer> listCustomer = new List<MailBroadcastDataAcess.Entity.Customer>();
    //        try
    //        {
    //            NullableDataReader sRead = (NullableDataReader)dalCam.GetListCustomer(currenPage, pageSize, CustomerName, Address, Phone,Mobile,Status,CountryID,CustomerCampaignID,createDate);
    //            while (sRead.Read())
    //            {
    //                MailBroadcastDataAcess.Entity.Customer customer = new MailBroadcastDataAcess.Entity.Customer();
    //                customer.CustomerID = sRead.GetInt32("CustomerID");
    //                customer.CustomerName = sRead.GetNullableString("CustomerName");
    //                customer.Address = sRead.GetNullableString("Address");
    //                customer.Phone = sRead.GetNullableString("Phone");
    //                customer.Mobile = sRead.GetNullableString("Mobile");
    //                customer.Status = sRead.GetNullableByte("Status");
    //                customer.CountryID = sRead.GetNullableInt32("CountryID");
    //                customer.CustomerCampaignID = sRead.GetNullableInt32("CustomerCampaignID");
    //                customer.CreateDate = sRead.GetNullableDateTime("CreateDate");
    //                TotalNumber = sRead.GetInt32("TotalNumber");
    //                listCustomer.Add(customer);
    //            }
    //            sRead.Close();
    //        }
    //        catch (Exception ex)
    //        {
    //            Console.Write(ex);
    //        }

    //        return listCustomer;
    //    }

    //    public List<MailBroadcastDataAcess.Entity.Customer> GetListCustomerByClientID(out int TotalNumber, int currenPage, int pageSize, int? clientID)
    //    {
    //        TotalNumber = 0;
    //        List<MailBroadcastDataAcess.Entity.Customer> listCustomer = new List<MailBroadcastDataAcess.Entity.Customer>();
    //        try
    //        {
    //            NullableDataReader sRead = (NullableDataReader)dalCam.GetListCustomerByClientID(currenPage, pageSize, clientID);
    //            while (sRead.Read())
    //            {
    //                MailBroadcastDataAcess.Entity.Customer customer = new MailBroadcastDataAcess.Entity.Customer();
    //                customer.CustomerID = sRead.GetInt32("CustomerID");
    //                customer.CustomerName = sRead.GetNullableString("CustomerName");
    //                customer.Address = sRead.GetNullableString("Address");
    //                customer.Phone = sRead.GetNullableString("Phone");
    //                customer.Mobile = sRead.GetNullableString("Mobile");
    //                customer.Status = sRead.GetNullableByte("Status");
    //                customer.CountryID = sRead.GetNullableInt32("CountryID");
    //                customer.CustomerCampaignID = sRead.GetNullableInt32("CustomerCampaignID");
    //                customer.CreateDate = sRead.GetNullableDateTime("CreateDate");
    //                TotalNumber = sRead.GetInt32("TotalNumber");
    //                listCustomer.Add(customer);
    //            }
    //            sRead.Close();
    //        }
    //        catch (Exception ex)
    //        {
    //            Console.Write(ex);
    //        }

    //        return listCustomer;
    //    }

    //    public List<MailBroadcastDataAcess.Entity.Customer> GetListCustomerByCustomerCampaignID(out int TotalNumber, int currenPage, int pageSize, int CustomerCampaignID)
    //    {
    //        TotalNumber = 0;
    //        List<MailBroadcastDataAcess.Entity.Customer> listCustomer = new List<MailBroadcastDataAcess.Entity.Customer>();
    //        try
    //        {
    //            NullableDataReader sRead = (NullableDataReader)dalCam.GetListCustomerByCustomerCampaignID(currenPage, pageSize, CustomerCampaignID);
    //            while (sRead.Read())
    //            {
    //                MailBroadcastDataAcess.Entity.Customer customer = new MailBroadcastDataAcess.Entity.Customer();
    //                customer.CustomerID = sRead.GetInt32("CustomerID");
    //                customer.CustomerName = sRead.GetNullableString("CustomerName");
    //                customer.Address = sRead.GetNullableString("Address");
    //                customer.Phone = sRead.GetNullableString("Phone");
    //                customer.Mobile = sRead.GetNullableString("Mobile");
    //                customer.Status = sRead.GetNullableByte("Status");
    //                customer.CountryID = sRead.GetNullableInt32("CountryID");
    //                customer.CustomerCampaignID = sRead.GetNullableInt32("CustomerCampaignID");
    //                customer.CreateDate = sRead.GetNullableDateTime("CreateDate");
    //                TotalNumber = sRead.GetInt32("TotalNumber");
    //                listCustomer.Add(customer);
    //            }
    //            sRead.Close();
    //        }
    //        catch (Exception ex)
    //        {
    //            Console.Write(ex);
    //        }

    //        return listCustomer;
    //    }

    //    public List<MailBroadcastDataAcess.Entity.Customer> GetListCustomerInCampaign(int CampaignID)
    //    {
    //        List<MailBroadcastDataAcess.Entity.Customer> listCustomer = new List<MailBroadcastDataAcess.Entity.Customer>();
    //        try
    //        {
    //            NullableDataReader sRead = (NullableDataReader)dalCam.GetListCustomerInCampaign(CampaignID);
    //            while (sRead.Read())
    //            {
    //                MailBroadcastDataAcess.Entity.Customer customer = new MailBroadcastDataAcess.Entity.Customer();
    //                customer.CustomerID = sRead.GetInt32("CustomerID");
    //                customer.CustomerName = sRead.GetNullableString("CustomerName");
    //                customer.Address = sRead.GetNullableString("Address");
    //                customer.Phone = sRead.GetNullableString("Phone");
    //                customer.Mobile = sRead.GetNullableString("Mobile");
    //                customer.Status = sRead.GetNullableByte("Status");
    //                customer.CountryID = sRead.GetNullableInt32("CountryID");
    //                customer.CustomerCampaignID = sRead.GetNullableInt32("CustomerCampaignID");
    //                customer.CreateDate = sRead.GetNullableDateTime("CreateDate");
    //                listCustomer.Add(customer);
    //            }
    //            sRead.Close();
    //        }
    //        catch (Exception ex)
    //        {
    //            Console.Write(ex);
    //        }

    //        return listCustomer;
    //    }


    //    public int CreateTypeCustomer(MailBroadcastDataAcess.Entity.TypeCustomer typeCustomer)
    //    {
    //        return dalCam.CreateTypeCustomer(typeCustomer);
    //    }

    //    public int UpdateTypeCustomer(MailBroadcastDataAcess.Entity.TypeCustomer typeCustomer)
    //    {
    //        return dalCam.UpdateTypeCustomer(typeCustomer);
    //    }

    //    public int DeleteTypeCustomer(int id)
    //    {
    //        return dalCam.DeleteTypeCustomer(id);
    //    }

    //    public MailBroadcastDataAcess.Entity.TypeCustomer GetTypeCustomerByID(int id)
    //    {
    //        MailBroadcastDataAcess.Entity.TypeCustomer typeCustomer = new MailBroadcastDataAcess.Entity.TypeCustomer();
    //        try
    //        {
    //            NullableDataReader sRead = (NullableDataReader)dalCam.GetTypeCustomerByID(id);
    //            while (sRead.Read())
    //            {
    //                typeCustomer.TypeCustomerID = sRead.GetInt32("TypeCustomerID");
    //                typeCustomer.TypeName = sRead.GetNullableString("TypeName");
    //                typeCustomer.TypeDes = sRead.GetNullableString("TypeDes");
    //                typeCustomer.TypeStatus = sRead.GetNullableByte("TypeStatus");
    //                typeCustomer.CreateDate = sRead.GetNullableDateTime("CreateDate");
    //            }
    //            sRead.Close();
    //        }
    //        catch (Exception ex)
    //        {
    //            Console.Write(ex);
    //        }

    //        return typeCustomer;
    //    }

    //    public List<MailBroadcastDataAcess.Entity.TypeCustomer> GetListTypeCustomerPaging(out int TotalNumber, int currenPage, int pageSize, string TypeName, string TypeDes,
    //       byte? TypeStatus, DateTime? createDate)
    //    {
    //        TotalNumber = 0;
    //        List<MailBroadcastDataAcess.Entity.TypeCustomer> listTypeCustomer = new List<MailBroadcastDataAcess.Entity.TypeCustomer>();
    //        try
    //        {
    //            NullableDataReader sRead = (NullableDataReader)dalCam.GetListTypeCustomerPaging(currenPage, pageSize, TypeName, TypeDes, TypeStatus,createDate);
    //            while (sRead.Read())
    //            {
    //                MailBroadcastDataAcess.Entity.TypeCustomer typeCustomer = new MailBroadcastDataAcess.Entity.TypeCustomer();
    //                typeCustomer.TypeCustomerID = sRead.GetInt32("TypeCustomerID");
    //                typeCustomer.TypeName = sRead.GetNullableString("TypeName");
    //                typeCustomer.TypeDes = sRead.GetNullableString("TypeDes");
    //                typeCustomer.TypeStatus = sRead.GetNullableByte("TypeStatus");
    //                typeCustomer.CreateDate = sRead.GetNullableDateTime("CreateDate");
    //                TotalNumber = sRead.GetInt32("TotalNumber");
    //                listTypeCustomer.Add(typeCustomer);
    //            }
    //            sRead.Close();
    //        }
    //        catch (Exception ex)
    //        {
    //            Console.Write(ex);
    //        }

    //        return listTypeCustomer;
    //    }


    //    public List<MailBroadcastDataAcess.Entity.TypeCustomer> GetListTypeCustomerNotPaging()
    //    {
    //        List<MailBroadcastDataAcess.Entity.TypeCustomer> listTypeCustomer = new List<MailBroadcastDataAcess.Entity.TypeCustomer>();
    //        try
    //        {
    //            NullableDataReader sRead = (NullableDataReader)dalCam.GetListTypeCustomer();
    //            while (sRead.Read())
    //            {
    //                MailBroadcastDataAcess.Entity.TypeCustomer typeCustomer = new MailBroadcastDataAcess.Entity.TypeCustomer();
    //                typeCustomer.TypeCustomerID = sRead.GetInt32("TypeCustomerID");
    //                typeCustomer.TypeName = sRead.GetNullableString("TypeName");
    //                typeCustomer.TypeDes = sRead.GetNullableString("TypeDes");
    //                typeCustomer.TypeStatus = sRead.GetNullableByte("TypeStatus");
    //                typeCustomer.CreateDate = sRead.GetNullableDateTime("CreateDate");
    //                listTypeCustomer.Add(typeCustomer);
    //            }
    //            sRead.Close();
    //        }
    //        catch (Exception ex)
    //        {
    //            Console.Write(ex);
    //        }

    //        return listTypeCustomer;
    //    }

    //    public int CreateTypeCustomerManage(MailBroadcastDataAcess.Entity.TypeCustomerManage typeCustomerManage)
    //    {
    //        return dalCam.CreateTypeCustomerManage(typeCustomerManage);
    //    }


    //    public int DeleteTypeCustomerManage(int id)
    //    {
    //        return dalCam.DeleteTypeCustomerManage(id);
    //    }

    //    public MailBroadcastDataAcess.Entity.TypeCustomerManage GetTypeCustomerManageByCustomerIDAndTypeCustomerID(int cusID,int typeID)
    //    {
    //        MailBroadcastDataAcess.Entity.TypeCustomerManage typeCustomerManage = new MailBroadcastDataAcess.Entity.TypeCustomerManage();
    //        try
    //        {
    //            NullableDataReader sRead = (NullableDataReader)dalCam.GetTypeCustomerManageByCustomerIDAndTypeCustomerID(cusID,typeID);
    //            while (sRead.Read())
    //            {
    //                typeCustomerManage.TypeCustomerManageID = sRead.GetInt32("TypeCustomerManageID");
    //                typeCustomerManage.TypeCustomerID = sRead.GetNullableInt32("TypeCustomerID");
    //                typeCustomerManage.CustomerID = sRead.GetNullableInt32("CustomerID");
    //                typeCustomerManage.CountryID = sRead.GetNullableInt32("CountryID");
    //            }
    //            sRead.Close();
    //        }
    //        catch (Exception ex)
    //        {
    //            Console.Write(ex);
    //        }

    //        return typeCustomerManage;
    //    }

    //    public int CreateLogSend(MailBroadcastDataAcess.Entity.LogSend log)
    //    {
    //        return dalCam.CreateLogSend(log);
    //    }

    //    public int UpdateLogSend(MailBroadcastDataAcess.Entity.LogSend log)
    //    {
    //        return dalCam.UpdateLogSend(log);
    //    }

    //    public int DeleteLogSend(int id)
    //    {
    //        return dalCam.DeleteLogSend(id);
    //    }

    //    public MailBroadcastDataAcess.Entity.LogSend GetLogSendByID(int id)
    //    {
    //        MailBroadcastDataAcess.Entity.LogSend log = new MailBroadcastDataAcess.Entity.LogSend();
    //        try
    //        {
    //            NullableDataReader sRead = (NullableDataReader)dalCam.GetLogSendByID(id);
    //            while (sRead.Read())
    //            {
    //                log.LogSendID = sRead.GetInt32("LogSendID");
    //                log.EmailID = sRead.GetNullableInt32("EmailID");
    //                log.Status = sRead.GetNullableByte("Status");
    //                log.LogContent = sRead.GetNullableString("LogContent");
    //                log.ConfigID = sRead.GetNullableInt32("ConfigID");
    //            }
    //            sRead.Close();
    //        }
    //        catch (Exception ex)
    //        {
    //            Console.Write(ex);
    //        }

    //        return log;
    //    }

    //    public List<MailBroadcastDataAcess.Entity.LogSend> GetListLogSendPaging(out int TotalNumber, int currenPage, int pageSize, int? EmailID)
    //    {
    //        TotalNumber = 0;
    //        List<MailBroadcastDataAcess.Entity.LogSend> listLogSend = new List<MailBroadcastDataAcess.Entity.LogSend>();
    //        try
    //        {
    //            NullableDataReader sRead = (NullableDataReader)dalCam.GetListLogSendPagingByEmailID(currenPage, pageSize, EmailID);
    //            while (sRead.Read())
    //            {
    //                MailBroadcastDataAcess.Entity.LogSend log = new MailBroadcastDataAcess.Entity.LogSend();
    //                log.LogSendID = sRead.GetInt32("LogSendID");
    //                log.EmailID = sRead.GetNullableInt32("EmailID");
    //                log.Status = sRead.GetNullableByte("Status");
    //                log.LogContent = sRead.GetNullableString("LogContent");
    //                log.ConfigID = sRead.GetNullableInt32("ConfigID");
    //                TotalNumber = sRead.GetInt32("TotalNumber");
    //                listLogSend.Add(log);
    //            }
    //            sRead.Close();
    //        }
    //        catch (Exception ex)
    //        {
    //            Console.Write(ex);
    //        }

    //        return listLogSend;
    //    }

    //    public int CreateCountry(MailBroadcastDataAcess.Entity.Country country)
    //    {
    //        return dalCam.CreateCountry(country);
    //    }

    //    public int UpdateCountry(MailBroadcastDataAcess.Entity.Country country)
    //    {
    //        return dalCam.UpdateCountry(country);
    //    }

    //    public int DeleteCountry(int id)
    //    {
    //        return dalCam.DeleteCountry(id);
    //    }

    //    public List<MailBroadcastDataAcess.Entity.Country> GetListCountryNotPaging()
    //    {
    //        List<MailBroadcastDataAcess.Entity.Country> listCountry = new List<MailBroadcastDataAcess.Entity.Country>();
    //        try
    //        {
    //            NullableDataReader sRead = (NullableDataReader)dalCam.GetListCountry();
    //            while (sRead.Read())
    //            {
    //                MailBroadcastDataAcess.Entity.Country country = new MailBroadcastDataAcess.Entity.Country();
    //                country.CountryID = sRead.GetInt32("CountryID");
    //                country.CountryName = sRead.GetNullableString("CountryName");
    //                country.CountryCode = sRead.GetNullableString("CountryCode");
    //                listCountry.Add(country);
    //            }
    //            sRead.Close();
    //        }
    //        catch (Exception ex)
    //        {
    //            Console.Write(ex);
    //        }

    //        return listCountry;
    //    }

    //    public MailBroadcastDataAcess.Entity.Country GetCountryByID(int id)
    //    {
    //        MailBroadcastDataAcess.Entity.Country country = new MailBroadcastDataAcess.Entity.Country();
    //        try
    //        {
    //            NullableDataReader sRead = (NullableDataReader)dalCam.GetCountryByID(id);
    //            while (sRead.Read())
    //            {
    //                country.CountryID = sRead.GetInt32("CountryID");
    //                country.CountryName = sRead.GetNullableString("CountryName");
    //                country.CountryCode = sRead.GetNullableString("CountryCode");
    //            }
    //            sRead.Close();
    //        }
    //        catch (Exception ex)
    //        {
    //            Console.Write(ex);
    //        }

    //        return country;
    //    }

    //    public int CreateAssignUser(MailBroadcastDataAcess.Entity.AssignUser assignUser)
    //    {
    //        return dalCam.CreateAssignUser(assignUser);
    //    }

    //    public int UpdateAssignUser(MailBroadcastDataAcess.Entity.AssignUser assignUser)
    //    {
    //        return dalCam.UpdateAssignUser(assignUser);
    //    }

    //    public int DeleteAssignUser(int id)
    //    {
    //        return dalCam.DeleteAssignUser(id);
    //    }
    //    /// <summary>
    //    /// Copy data to temp table
    //    /// </summary>
    //    /// <param name="sheetName"></param>
    //    /// <param name="filePath"></param>
    //    /// <param name="IsHDR"></param>
    //    /// <param name="tableName"></param>
    //    /// <returns></returns>
    //    public void SaveDatatoTempTable(string sheetName, string filePath, string IsHDR, string tableName)
    //    {
    //        dalCam.ImportExcelToDB(sheetName, filePath, IsHDR, tableName);
    //    }
    //    /// <summary>
    //    /// Get List CustomerId and list tempID(copycode) inserted 
    //    /// </summary>
    //    /// <returns></returns>
    //    public List<MailBroadcastDataAcess.Entity.CopyTempData> GetListCopyDataFromTempTable()
    //    {
    //        List<MailBroadcastDataAcess.Entity.CopyTempData> list = new List<MailBroadcastDataAcess.Entity.CopyTempData>();
    //        try
    //        {
    //            NullableDataReader sRead = (NullableDataReader)dalCam.CopyDataFromTempData();
    //            while (sRead.Read())
    //            {
    //                MailBroadcastDataAcess.Entity.CopyTempData copy = new MailBroadcastDataAcess.Entity.CopyTempData();
    //                copy.Id = sRead.GetNullableInt32("id");
    //                copy.Copycode = sRead.GetNullableInt32("copycode");
    //                list.Add(copy);
    //            }
    //            sRead.Close();
    //        }
    //        catch (Exception ex)
    //        {
    //            Console.Write(ex);
    //        }

    //        return list;
    //    }

    //    /// <summary>
    //    /// Get TempData by ID
    //    /// </summary>
    //    /// <param name="id"></param>
    //    /// <returns></returns>
    //    public MailBroadcastDataAcess.Entity.TempData GetTempDataByID(int id)
    //    {
    //        MailBroadcastDataAcess.Entity.TempData tempdata = new MailBroadcastDataAcess.Entity.TempData();
    //        try
    //        {
    //            NullableDataReader sRead = (NullableDataReader)dalCam.GetTempDataByID(id);
    //            while (sRead.Read())
    //            {
    //                tempdata.TempID = sRead.GetInt32("TempID");
    //                tempdata.CustomerName = sRead.GetNullableString("CustomerName");
    //                tempdata.Address = sRead.GetNullableString("Address");
    //                tempdata.Phone = sRead.GetNullableString("Phone");
    //                tempdata.Mobile = sRead.GetNullableString("Mobile");
    //                tempdata.Email1 = sRead.GetNullableString("Email1");
    //                tempdata.Email2 = sRead.GetNullableString("Email2");
    //                tempdata.Email3 = sRead.GetNullableString("Email3");
    //                tempdata.Status = sRead.GetNullableByte("Status");
    //                tempdata.CountryID = sRead.GetNullableInt32("CountryID");
    //                tempdata.TypeCustomerID = sRead.GetNullableInt32("TypeCustomerID");

    //            }
    //            sRead.Close();
    //        }
    //        catch (Exception ex)
    //        {
    //            Console.Write(ex);
    //        }

    //        return tempdata;
    //    }

    //    public int DeleteTempData(int id)
    //    {
    //        return dalCam.DeleteTempData(id);
    //    }

    //    public MailBroadcastDataAcess.Entity.Client GetClientByCampaignID(int id)
    //    {
    //        MailBroadcastDataAcess.Entity.Client client = new MailBroadcastDataAcess.Entity.Client();
    //        try
    //        {
    //            NullableDataReader sRead = (NullableDataReader)dalCam.GetClientByCampaign(id);
    //            while (sRead.Read())
    //            {
    //                client.ClientID = sRead.GetInt32("ClientID");
    //                client.Name = sRead.GetNullableString("Name");
    //                client.UserCreate = sRead.GetNullableInt32("UserCreate");
    //                client.Deploy = sRead.GetNullableBoolean("Deploy");
    //                client.CreateDate = sRead.GetNullableDateTime("CreateDate");
    //                client.Address = sRead.GetNullableString("Address");
    //                client.Email = sRead.GetNullableString("Email");
    //                client.Phone = sRead.GetNullableString("Phone");

    //            }
    //            sRead.Close();
    //        }
    //        catch (Exception ex)
    //        {
    //            Console.Write(ex);
    //        }

    //        return client;
    //    }

        

    //    public void UpdateStatusCampaign(int? id, int? newstatus)
    //    {
    //        if (id != null && newstatus != null)
    //        {
    //            dalCam.UpdateCampaignStatus((int)id, (int)newstatus);
    //        }
            
    //    }

    //    public void UpdateStatusTemplate(int? id, int? newstatus)
    //    {
    //        if (id != null && newstatus != null)
    //        {
    //            dalCam.UpdateTemplateStatus((int)id, (int)newstatus);
    //        }

    //    }

    //    public void UpdateStatusMailSetting(int? id, int? newstatus)
    //    {
    //        if (id != null && newstatus != null)
    //        {
    //            dalCam.UpdateMailSettingStatus((int)id, (int)newstatus);
    //        }

    //    }

    //    public void UpdateStatusTypeCustomer(int? id, int? newstatus)
    //    {
    //        if (id != null && newstatus != null)
    //        {
    //            dalCam.UpdateTypeCustomerStatus((int)id, (int)newstatus);
    //        }

    //    }

    //    public List<MailBroadcastDataAcess.Entity.ClientStaffCampaign> GetListStaffIDByCampaignID(int id)
    //    {
    //        List<MailBroadcastDataAcess.Entity.ClientStaffCampaign> list = new List<MailBroadcastDataAcess.Entity.ClientStaffCampaign>();
    //        try
    //        {
    //            NullableDataReader sRead = (NullableDataReader)dalCam.GetListStaffIDByCampaignID(id);
    //            while (sRead.Read())
    //            {
    //                MailBroadcastDataAcess.Entity.ClientStaffCampaign staffclient = new MailBroadcastDataAcess.Entity.ClientStaffCampaign();
    //                staffclient.ClientStaffCCID = sRead.GetInt32("ClientStaffCCID");
    //                staffclient.StaffID = sRead.GetNullableInt32("StaffID");
    //                staffclient.CampaignID = sRead.GetNullableInt32("CampaignID");
    //                staffclient.CreateDate = sRead.GetNullableDateTime("CreateDate");
    //                staffclient.ModifiedLast = sRead.GetNullableDateTime("ModifiedLast");
    //                list.Add(staffclient);
    //            }
    //            sRead.Close();
    //        }
    //        catch (Exception ex)
    //        {
    //            Console.Write(ex);
    //        }

    //        return list;
    //    }

    //    public List<MailBroadcastDataAcess.Entity.AssignUser> GetListAssignUserByCampaignID(int id)
    //    {
    //        List<MailBroadcastDataAcess.Entity.AssignUser> list = new List<MailBroadcastDataAcess.Entity.AssignUser>();
    //        try
    //        {
    //            NullableDataReader sRead = (NullableDataReader)dalCam.GetListAssignUserByCampaignID(id);
    //            while (sRead.Read())
    //            {
    //                MailBroadcastDataAcess.Entity.AssignUser assignUser = new MailBroadcastDataAcess.Entity.AssignUser();
    //                assignUser.AssignID = sRead.GetInt32("AssignID");
    //                assignUser.CampaignID = sRead.GetNullableInt32("CampaignID");
    //                assignUser.UserID = sRead.GetNullableInt32("UserID");
    //                list.Add(assignUser);
    //            }
    //            sRead.Close();
    //        }
    //        catch (Exception ex)
    //        {
    //            Console.Write(ex);
    //        }

    //        return list;
    //    }

    //    public List<MailBroadcastDataAcess.Entity.AttachFile> GetListAttachFileByCampaignID(int id)
    //    {
    //        List<MailBroadcastDataAcess.Entity.AttachFile> list = new List<MailBroadcastDataAcess.Entity.AttachFile>();
    //        try
    //        {
    //            NullableDataReader sRead = (NullableDataReader)dalCam.GetListAttachFileByCampaignID(id);
    //            while (sRead.Read())
    //            {
    //                MailBroadcastDataAcess.Entity.AttachFile attachFile = new MailBroadcastDataAcess.Entity.AttachFile();
    //                attachFile.AttachID = sRead.GetInt32("AttachID");
    //                attachFile.FileExtend = sRead.GetNullableString("FileExtend");
    //                attachFile.Location = sRead.GetNullableString("Location");
    //                attachFile.Status = sRead.GetNullableByte("Status");
    //                attachFile.TypeMail = sRead.GetNullableBoolean("TypeMail");
    //                attachFile.FileName = sRead.GetNullableString("FileName");
    //                attachFile.TypeAttach = sRead.GetNullableByte("TypeAttach");
    //                attachFile.CampaignID = sRead.GetNullableInt32("CampaignID");
    //                list.Add(attachFile);
    //            }
    //            sRead.Close();
    //        }
    //        catch (Exception ex)
    //        {
    //            Console.Write(ex);
    //        }

    //        return list;
    //    }


    //    public List<MailBroadcastDataAcess.Entity.CustomerCampaign> GetListCustomerCampaignByCampaignID(int id)
    //    {
    //        List<MailBroadcastDataAcess.Entity.CustomerCampaign> list = new List<MailBroadcastDataAcess.Entity.CustomerCampaign>();
    //        try
    //        {
    //            NullableDataReader sRead = (NullableDataReader)dalCam.GetListCustomerCampaignByCampaignID(id);
    //            while (sRead.Read())
    //            {
    //                MailBroadcastDataAcess.Entity.CustomerCampaign customerCampaign = new MailBroadcastDataAcess.Entity.CustomerCampaign();
    //                customerCampaign.CustomerCampaignID = sRead.GetInt32("CustomerCampaignID");
    //                customerCampaign.CampaignID = sRead.GetNullableInt32("CampaignID");
    //                customerCampaign.Status = sRead.GetNullableByte("Status");
    //                customerCampaign.ClientID = sRead.GetNullableInt32("ClientID");
    //                list.Add(customerCampaign);
    //            }
    //            sRead.Close();
    //        }
    //        catch (Exception ex)
    //        {
    //            Console.Write(ex);
    //        }

    //        return list;
    //    }

    //    public List<MailBroadcastDataAcess.Entity.Country> GetListCountryPaging(out int TotalNumber, int currenPage, int pageSize, string CountryName, string CountryCode)
    //    {
    //        TotalNumber = 0;
    //        List<MailBroadcastDataAcess.Entity.Country> listCountry = new List<MailBroadcastDataAcess.Entity.Country>();
    //        try
    //        {
    //            NullableDataReader sRead = (NullableDataReader)dalCam.GetListCountryPaging(currenPage, pageSize, CountryName, CountryCode);
    //            while (sRead.Read())
    //            {
    //                MailBroadcastDataAcess.Entity.Country country = new MailBroadcastDataAcess.Entity.Country();
    //                country.CountryID = sRead.GetInt32("CountryID");
    //                country.CountryName = sRead.GetNullableString("CountryName");
    //                country.CountryCode = sRead.GetNullableString("CountryCode");
    //                TotalNumber = sRead.GetInt32("TotalNumber");
    //                listCountry.Add(country);
    //            }
    //            sRead.Close();
    //        }
    //        catch (Exception ex)
    //        {
    //            Console.Write(ex);
    //        }

    //        return listCountry;
    //    }

    }
}
